using System;
using System.Collections.Generic;
using System.Linq;
using System.Linq.Expressions;
using System.Text;
using MMM.Core.Domain;
using ServiceStack.ServiceHost;
using System.ComponentModel;
using System.ComponentModel.DataAnnotations;
using MMM.Services.Base;
using MMM.Services.Operations;
using MMM.Services.Type;
using MMM.Core;
using MMM.Services.Response;
using ServiceStack.OrmLite;
using ServiceStack.ServiceInterface;
using MMM.Services.Operations.Sys;


namespace MMM.Services
{

    public class FunctionService : BaseService<Function>
    {
        public override object OnGet(Function request)
        {
            List<Function> funcList = new List<Function>();
            if (request.ModuleID != null)
            {
                funcList = Rep.GetEntities(t => t.ModuleID == request.ModuleID, s => s.OrderIndex, true).ToList();
            }

            return new OperationResult<Function>(funcList, funcList.Count());
        }

        public override object OnPost(Function request)
        {
            var obj= base.OnPost(request);
            this.GetCacheClient().Remove("functions");
            this.GetCacheClient().Remove("dd");
            return obj;
        }
    }

    public class FunctionDeleteService : BaseDeleteService<Function, DelelteFunction>
    {

    }
}
